home *** CD-ROM | disk | FTP | other *** search
/ Clickx 96 / Clickx 96.iso / software / tools / tool / xbmc-10.1.exe / system / shaders / yuv2rgb_d3d.fx < prev    next >
Encoding:
Text File  |  2011-03-08  |  2.5 KB  |  113 lines

  1. /*
  2.  *      Copyright (C) 2005-2010 Team XBMC
  3.  *      http://www.xbmc.org
  4.  *
  5.  *  This Program is free software; you can redistribute it and/or modify
  6.  *  it under the terms of the GNU General Public License as published by
  7.  *  the Free Software Foundation; either version 2, or (at your option)
  8.  *  any later version.
  9.  *
  10.  *  This Program is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13.  *  GNU General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU General Public License
  16.  *  along with XBMC; see the file COPYING.  If not, write to
  17.  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *  http://www.gnu.org/copyleft/gpl.html
  19.  *
  20.  */
  21.  
  22. texture g_YTexture;
  23. texture g_UTexture;
  24. texture g_VTexture;
  25. float4x4 g_ColorMatrix;
  26.  
  27. #ifdef SINGLEPASS
  28.  
  29. // Color conversion + bilinear resize in one pass
  30.  
  31. sampler YSampler =
  32.   sampler_state {
  33.     Texture = <g_YTexture>;
  34.     AddressU = CLAMP;
  35.     AddressV = CLAMP;
  36.     MipFilter = LINEAR;
  37.     MinFilter = LINEAR;
  38.     MagFilter = LINEAR;
  39.   };
  40.  
  41. #else
  42.  
  43. // Color conversion only
  44.  
  45. sampler YSampler =
  46.   sampler_state {
  47.     Texture = <g_YTexture>;
  48.     AddressU = CLAMP;
  49.     AddressV = CLAMP;
  50.     MipFilter = LINEAR;
  51.     MinFilter = POINT;
  52.     MagFilter = POINT;
  53.   };
  54.  
  55. #endif
  56.  
  57. sampler USampler =
  58.   sampler_state {
  59.     Texture = <g_UTexture>;
  60.     AddressU = CLAMP;
  61.     AddressV = CLAMP;
  62.     MipFilter = LINEAR;
  63.     MinFilter = LINEAR;
  64.     MagFilter = LINEAR;
  65.   };
  66.  
  67. sampler VSampler =
  68.   sampler_state
  69.   {
  70.     Texture = <g_VTexture>;
  71.     AddressU = CLAMP;
  72.     AddressV = CLAMP;
  73.     MipFilter = LINEAR;
  74.     MinFilter = LINEAR;
  75.     MagFilter = LINEAR;
  76.   };
  77.  
  78. struct VS_OUTPUT
  79. {
  80.   float4 Position   : POSITION;
  81.   float2 TextureY   : TEXCOORD0;
  82.   float2 TextureU   : TEXCOORD1;
  83.   float2 TextureV   : TEXCOORD2;
  84. };
  85.  
  86. struct PS_OUTPUT
  87. {
  88.   float4 RGBColor : COLOR0;
  89. };
  90.  
  91. PS_OUTPUT YUV2RGB( VS_OUTPUT In)
  92. {
  93.   PS_OUTPUT OUT;
  94.   float4 YUV = float4(tex2D (YSampler, In.TextureY).x
  95.                     , tex2D (USampler, In.TextureU).x
  96.                     , tex2D (VSampler, In.TextureV).x
  97.                     , 1.0);
  98.   OUT.RGBColor = mul(YUV, g_ColorMatrix);
  99.   OUT.RGBColor.a = 1.0;
  100.   return OUT;
  101. }
  102.  
  103. technique YUV2RGB_T
  104. {
  105.   pass P0
  106.   {
  107.     PixelShader  = compile ps_2_0 YUV2RGB();
  108.     ZEnable = False;
  109.     FillMode = Solid;
  110.     FogEnable = False;
  111.   }
  112. };
  113.